import { Button, Checkbox, DatePicker, Form, Input, Radio, Select, message } from 'antd';
import React, { useEffect, useState } from 'react';

import type { CheckboxValueType } from 'antd/es/checkbox/Group';
import useWebSocket from '@/hooks/UseWebsocket';
import moment from 'moment';
import dayjs from 'dayjs';
import { AddAdminCard, getBuildingsList } from '../request';
import AdminCardmodel from '../../HourCard/components/AdminCardmodel';
import { GetAdminCard, checkoutAdminCard } from '@/pages/account/Business/service';
import { getCardExpire } from './request';
import { useDetermineCardType } from '@/hooks/DetermineCardType';
import { removeDuplicateDong } from '../DuplicateBuildings';
import { useIntl } from '@umijs/max';
import { Read_Card, SendCard } from '@/utils/Send';
import { result } from 'lodash';
// import { useDetermineCardType } from '@/hooks/DetermineCardType';
const CheckboxGroup = Checkbox.Group;

// const plainOptions = ['1栋', '2栋', '3栋'];
const defaultCheckedList = ['1栋'];
type Currency = 'fen' | 'shi';
const { Option } = Select;
interface PriceValue {
  number?: number;
  currency?: Currency;
}

interface PriceInputProps {
  value?: PriceValue;
  onChange?: (value: PriceValue) => void;
}

interface Prpos {
  msg: string;
  Bonlist?: any;
  healthlist?: any;
  getfloor?: any;
}
const Rightbuildings: React.FC<Prpos> = ({ msg, Bonlist, healthlist, getfloor }) => {
  const [checkedList, setCheckedList] = useState<CheckboxValueType[]>(defaultCheckedList);
  const [excludeNumber] = useState([]);
  const [excludeNumber2] = useState([]);
  const [sendMsg, setsendMsg] = useState<any>(); // 发送消息
  const [CardMessage, setCardMessage] = useState<any>(); // 接受消息
  const [type, setType] = useState<string>(''); // 成功后的提示消息
  const [checkIntimer] = useState(moment().add(7, 'days'));
  const [plainOptions, setplainOptions] = useState();
  const defaultChecked = ['1栋'];
  const intl = useIntl();
  // 计算7天后的时间
  const [form] = Form.useForm();
  const getlist = async () => {
    const buildlist = await getBuildingsList();
    if (buildlist.data.list) {
      const newBon = buildlist.data.list.map(
        (item: { bno: React.SetStateAction<undefined> }) => item.bno,
      );
      const arr2 = newBon.map((item: string) => {
        return item + intl.formatMessage({ id: 'card.building' });
      });
      setplainOptions(arr2);
    }
  };
  useEffect(() => {
    getlist();
    if (msg == '应急卡') {
      // setexcludeArr(['开反锁'])
    }
  }, []);

  // const [_, sendMessage, CardMessage, isConnected] = useWebSocket({
  //   url: 'ws://127.0.0.1:9909',
  //   onOpen: () => {
  //     if (sendMsg) {
  //       sendMessage(sendMsg);
  //     }
  //   },
  //   onClose: () => {
  //     //连接关闭
  //     console.log('WebSocket disconnected');
  //   },
  //   onError: (event) => {
  //     //连接异常
  //     console.error('WebSocket error:', event);
  //   },
  //   onMessage: (onmsg) => {
  //     //收到消
  //     setCardMessage(JSON.parse(onmsg));
  //   },
  // });

  // 监听数据改变来发送消息
  // useEffect(() => {
  //   if (isConnected && sendMsg) {
  //     sendMessage(sendMsg);
  //   }
  // }, [sendMsg, isConnected]);

  const values = form.getFieldsValue();
  const AddAdminCardLog = async (
    msg: string,
    cardTypeNum: number,
    username: string,
    endtimes: string,
    cardid: string,
    sendMsg: any,
    build: any,
    bon: string = '',
    floor?: string,
  ) => {
    let bonStr = removeDuplicateDong(bon);

    let data = await AddAdminCard({
      cardHolder: username,
      cardType: cardTypeNum,
      expirationDate: endtimes,
      isOpenLocked: '',
      isMute: '',
      status: 1,
      buildingName: build.length ? build.join(',') : bonStr,
      floor: floor,
      cardNum: cardid,
      cmdInfo: JSON.stringify(sendMsg),
    });

    if (data.code == 0) {
      message.success(intl.formatMessage({id:"ManageCards.Card issuance successful."}));
    } else {
      message.error(intl.formatMessage({id:"ManageCards.Card issuance failed."}));
    }
  };

  useEffect(() => {
    if (CardMessage) {
      console.log('返回', CardMessage);
      console.log('type =》', type);
      if (type == '读卡成功') {
        console.log(CardMessage);
        AdminSendCard(CardMessage);
        setcardID(CardMessage.cardid);
      }
      if (CardMessage.result == 0) {
        // 发卡成功后新增发卡记录
        switch (type) {
          case '总卡发卡成功':
            AddAdminCardLog(
              type,
              2,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
            );
            break;
          case '梯控卡发卡成功':
            AddAdminCardLog(
              type,
              11,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
            );
            break;
          case '楼栋卡,发卡成功':
            AddAdminCardLog(
              type,
              3,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              values.build,
            );
            break;
          case '层控卡,发卡成功':
            AddAdminCardLog(
              type,
              4,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
              getfloor.bon,
              getfloor.floor,
            );
            break;
          case '应急卡,发卡成功':
            AddAdminCardLog(
              type,
              6,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
            );
            break;
          case '卫生卡,发卡成功':
            AddAdminCardLog(
              type,
              7,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
              getfloor.bon,
              getfloor.floor,
            );
            break;
          case '常开卡,发卡成功':
            AddAdminCardLog(
              type,
              8,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
            );
            break;
          case '授权卡,发卡成功':
            AddAdminCardLog(
              type,
              18,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
            );
            setNumber(999999);
            break;
          case '员工卡,发卡成功':
            AddAdminCardLog(
              type,
              10,
              values.username,
              sendMsg.endtime,
              CardMessage.cardid,
              sendMsg,
              [],
              getfloor.bon,
              getfloor.floor,
            );
            break;

          case '读卡成功1':
            setcardID(CardMessage.cardid);
            if (CardMessage.cardid) {
              if (CardMessage.result == 0) {
                ReadAdminCard(CardMessage.cardid, CardMessage.cardclass);
              } else {
                message.error(CardMessage.msg);
              }
            } else {
              message.error(CardMessage.msg);
            }
            break;
          case '退卡成功':
            checkoutAdminCard(cardID);
            message.success(intl.formatMessage({id:"ManageCards.return successful"}));
            setcardID('');
            setNumber(999999);
            break;
        }

        form.resetFields();
      } else {
        if (CardMessage.msg != '空卡') {
          message.error(CardMessage.msg);
        }
      }
    }
  }, [CardMessage]);

  const [cardID, setcardID] = useState('');

  const onChange = (list: CheckboxValueType[]) => {
    setCheckedList(list);
  };

  const [SenderTimer, setSenderTimer] = useState();
  const [excludeArr, setexcludeArr] = useState([]);
  const [excludeNumberArr, setexcludeNumberArr] = useState([]);
  const AdminSendCard = async (card: any) => {
    if (card.msg == '空卡') {
      const timeString = SenderTimer;
      const date = dayjs(timeString);
      const formattedDate = date.format('YYYY-MM-DD HH:mm:ss');
      let data: any = {
        cardclass: '',
        uuid: '',
        roomid: '',
        begintime: '',
        endtime: formattedDate,
        t1: '1',
        t2: '1',
        t3: '1',
        t4: '0',
        t5: '1',
        t6: '0',
        t7: '0',
        t8: '0',
        roomlist: '',
      };
      const excludeNumber2 = excludeNumberArr || [];
      if (msg == '梯控启停卡') {
        let result = values.build.map((item: string) => {
          let str = parseInt(item).toString(16).toUpperCase().padStart(2, '0');
          return `${str}000000`;
        });

        const res = await getCardExpire({
          cardType: '2',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });
        data['cardType'] = '23';
        data.begintime = res.data.expire_date;
        data.cardclass = values.TKGroup;
        data.uuid = 'Elevatorcard';
        data.roomid = values.TKGroup == 'Elevatorcard' ? result[0] : '00000000';
        data.roomlist = values.TKGroup == 'Elevatorcard' ? result.join('') : '';
        data.t4 = '0';
        data.t6 = '0';
        data.t8 = '0'; // 反锁
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
               let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);
        setType('梯控卡发卡成功');
      }
      if (msg == '总卡') {
        const res = await getCardExpire({
          cardType: '2',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });

        data.begintime = res.data.expire_date;
        data.cardclass = 'mastercard';
        data.uuid = 'mastercard';
        data.roomid = '00000000';
        data.t4 = '0';
        data.t6 = '0';
        data.t8 = '0'; // 反锁
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
        let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);
        setType('总卡发卡成功');
      }
      if (msg == '楼栋卡') {
        let result = values.build.map((item: string) => {
          let str = parseInt(item).toString(16).toUpperCase().padStart(2, '0');
          return `${str}000000`;
        });
        const res = await getCardExpire({
          cardType: '3',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });
        data.begintime = res.data.expire_date;
        data.cardclass = 'buildingcard';
        data.uuid = 'buildingcard';
        data.roomid = result[0];
        data.roomlist = result.join('');
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '开反锁') {
              data.t8 = '1';
            }
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
                       let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);
        setType('楼栋卡,发卡成功');
      }
      if (msg == '层控卡') {
        //   楼层卡的前4位：2位16进制的楼栋id+2位16进制的楼层号组成

        let bon = Bonlist[0];
        if (!bon) {
          return message.error(intl.formatMessage({id:"ManageCards.Please select the floor first"}));
        }
        const res = await getCardExpire({
          cardType: '4',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });
        data.cardclass = 'floorcard';
        data.uuid = 'floorcard';
        data['groupid'] = '0';
        data.begintime = res.data.expire_date;
        data.roomid = bon;
        data.roomlist = `${Bonlist.join('')}`;
        // console.log(Bonlist)
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '开反锁') {
              data.t8 = '1';
            }
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }

        let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);
        setType('层控卡,发卡成功');
      }
      if (msg == '员工卡') {
        //   楼层卡的前4位：2位16进制的楼栋id+2位16进制的楼层号组成
        let bon = Bonlist[0];
        if (!bon) {
          return message.error(intl.formatMessage({id:"ManageCards.Please select the floor first"}));
        }

        const res = await getCardExpire({
          cardType: '10',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });

        data.cardclass = 'personnelcard';
        data.uuid = 'personnelcard';
        data['groupid'] = '0';
        data.begintime = res.data.expire_date;
        data.roomid = bon;
        data.roomlist = `${Bonlist.join('').slice(8)}`;
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '开反锁') {
              data.t8 = '1';
            }
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
                let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);

        setType('员工卡,发卡成功');
      }
      if (msg == '应急卡') {
        data.cardclass = 'emergencycard';
        data.uuid = 'emergencycard';
        data.roomid = '00000000';
        data.roomlist = '00000000';
        const res = await getCardExpire({
          cardType: '6',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });
        data.begintime = res.data.expire_date;
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '开反锁') {
              data.t8 = '1';
            }
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
                let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);
        setType('应急卡,发卡成功');
      }

      if (msg == '卫生卡') {
        const res = await getCardExpire({
          cardType: '7',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });
        // if (!healthlist)
        let health = healthlist[0];
        if (!health) {
          return message.error(intl.formatMessage({id:"ManageCards.Please select the floor first"}));
        }
        data.cardclass = 'staffcard';
        data.uuid = 'staffcard';
        data.begintime = res.data.expire_date;
        data.roomid = health;
        data.roomlist = `${healthlist.join('')}`;
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '开反锁') {
              data.t8 = '1';
            }
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
                let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);

        setType('卫生卡,发卡成功');
      }

      if (msg == '常开卡') {
        const res = await getCardExpire({
          cardType: '8',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });
        data.cardclass = 'alwaysopencard';
        data.uuid = 'alwaysopencard';
        data.roomid = 'FFFFFFFF';
        data.begintime = res.data.expire_date;
        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '开反锁') {
              data.t8 = '1';
            }
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
                let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);

        setType('常开卡,发卡成功');
      }
      if (msg == '授权卡') {
        const res = await getCardExpire({
          cardType: '18',
          overWrite: excludeNumber2.includes(1) ? 1 : 0,
        });
        data.begintime = res.data.expire_date;
        data.cardclass = 'setvipcard';
        data.uuid = 'setvipcard';
        data.roomid = 'FFFFFFFF';

        if (excludeArr.length) {
          excludeArr.map((item: string) => {
            if (item == '开反锁') {
              data.t8 = '1';
            }
            if (item == '静音') {
              data.t7 = '1';
            }
          });
        }
        // 默认时间 没有修改input框中的数值
        if (values.price == undefined) {
          // 判断选择的是小时还是分钟
          if (currency == 'shi') {
            data['timelog'] = 999999 * 60;
            data['groupid'] = '999999';
          } else {
            data['timelog'] = 999999;
            data['groupid'] = '999999';
          }
        } else {
          // 判断的是修改了input框中的值 然后判断选择的是分钟还是小时
          if (currency == 'shi') {
            data['timelog'] = parseInt(values.price) * 60;
            data['groupid'] = values.price;
          } else {
            data['timelog'] = parseInt(values.price);
            data['groupid'] = values.price;
          }
        }
                let Res = await SendCard(data);
        setCardMessage(Res);
        setsendMsg(data);
        setType('授权卡,发卡成功');
      }
      console.log('sendMsg', data);
    } else {
      if (card.cardclass == 'guestcard') {
        message.error(intl.formatMessage({id:"ManageCards.guest card return card"}));
      }
      if (card.cardclass == 'losscard') {
        message.error(intl.formatMessage({id:"ManageCards.Loss card return card"}));
      }
      if (card.cardclass == 'setcard') {
        message.error(intl.formatMessage({id:"This card is a setup card"}));
      }
      if (
        card.cardclass == 'mastercard' ||
        card.cardclass == 'personnelcard' ||
        card.cardclass == 'buildingcard' ||
        card.cardclass == 'floorcard' ||
        card.cardclass == 'setvipcard' ||
        card.cardclass == 'alwaysopencard' ||
        card.cardclass == 'staffcard' ||
        card.cardclass == 'emergencycard'
      ) {
        message.error(intl.formatMessage({id:"ManageCards.This card is a management card"}));
        let data: any = await GetAdminCard(card.cardid);
        if (data.code === 0) {
          // 打开弹窗
          if (data.data.id) {
            setuseMsg(data.data);
            setuseflag(true);
          } else {
            message.error(intl.formatMessage({id:"ManageCards.Unknown card"}));
          }
        }
      }
    }
  };

  // 确认发卡

  function debounce(
    func: { (values: any): Promise<void>; (arg0: any): void },
    wait: number | undefined,
  ) {
    let timeout: string | number | NodeJS.Timeout | undefined;
    return function (...args: any) {
      clearTimeout(timeout);
      timeout = setTimeout(() => {
        func(...args);
      }, wait);
    };
  }
  const onFinish = debounce(async (values: any) => {
    // let retult = { cardclass: 'readcard', uuid: '12345', isclear: '0' };
    // setsendMsg(retult);

    let retult = await Read_Card();
    console.log('retult', retult);
    setCardMessage(retult);
    setType('读卡成功');

    // console.log("values ", values)

    setSenderTimer(values.timer.$d);
    setexcludeArr(values.excludeNumber || []);
    setexcludeNumberArr(values.excludeNumber2);
  }, 300);

  const onFinishFailed = (errorInfo: any) => {
    console.log('Failed:', errorInfo);
  };

  const [number, setNumber] = useState(999999);
  const [currency, setCurrency] = useState<Currency>('fen');

  const triggerChange = (changedValue: { number?: number; currency?: Currency }) => {
    onChange?.({ number, currency, ...values, ...changedValue });
  };

  const onNumberChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    const newNumber = parseInt(e.target.value || '0', 10);
    if (Number.isNaN(number)) {
      return;
    }
    if (!('number' in values)) {
      setNumber(newNumber);
    }
    ({ number: newNumber });
  };

  const onCurrencyChange = (newCurrency: Currency) => {
    console.log('newCurrency', newCurrency);
    if (!('currency' in values)) {
      setCurrency(newCurrency);
    }
    triggerChange({ currency: newCurrency });
  };

  const [useflag, setuseflag] = useState(false);
  const [useMsg, setuseMsg] = useState<CardMSg | any>({});
  const [cardType] = useState(intl.formatMessage({id:"card.Management card"}));
  const reTurnadmin = async () => {
    let res = await Read_Card();
    console.log('retult', res);

    if (res.msg == '空卡')
      return message.error(intl.formatMessage({ id: 'ManageCards.Empty card' }));

    setCardMessage(res);
    setType('读卡成功1');
  };
  function isEmptyObject(obj: {}) {
    return typeof obj === 'object' && Object.keys(obj).length === 0;
  }
  const ReadAdminCard = async (card: string, type: string): Promise<any> => {
    if (type == 'losscard' || type == 'guestcard' || type == 'setcard') {
      let [res] = useDetermineCardType(type);
      return message.error(intl.formatMessage({ id: 'Table.Room Card Loss' }, { card:res }));
    }
    if (card) {
      let data: any = await GetAdminCard(card);
      console.log(data);
      if (data.code === 0) {
        // 打开弹窗
        const IsObjFlag = isEmptyObject(data.data); // 判断是否是空对象
        if (IsObjFlag == false) {
          setuseMsg(data.data);
          setuseflag(true);
        } else {
          message.error(intl.formatMessage({ id: 'ManageCards.Unknown card' }));
        }
      }
      setuseflag(true);
    }
  };

  const handleOkFlag = () => {
    setuseflag(false);
  };
  return (
    <>
      {useflag && (
        <AdminCardmodel
          useflag={useflag}
          useMsg={useMsg}
          cardType={cardType}
          handleOkFlag={handleOkFlag}
          setsendMsg={setsendMsg}
          setType={setType}
        />
      )}

      <div style={{ position: 'absolute', right: '20px' }}>
        <Button type="primary" danger onClick={reTurnadmin}>
          {intl.formatMessage({ id: 'Lost.Return card' })}
        </Button>
      </div>
      <div style={{ height: '100%' }}>
        <Form
          name="basic"
          labelCol={{ span: msg == '员工卡' || msg == '层控卡' || msg == '卫生卡' ? 8 : 3 }}
          wrapperCol={{ span: 10 }}
          // style={{ maxWidth: 820 }}
          form={form}
          onFinish={onFinish}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          {msg == '梯控启停卡' && (
            <Form.Item<any>
              label={intl.formatMessage({ id: 'ManageCards.Elevator control version' })}
              name="TKGroup"
              initialValue={'Elevatorcard'}
              rules={[
                {
                  required: true,
                  message: intl.formatMessage({ id: 'ManageCards.Select Elevator control' }),
                },
              ]}
            >
              <Radio.Group size="large">
                <Radio.Button value="Elevatorcard">
                  {intl.formatMessage({ id: 'ManageCards.swipe once' })}
                </Radio.Button>
                <Radio.Button value="mastercard">
                  {intl.formatMessage({ id: 'ManageCards.swipe Three' })}
                </Radio.Button>
              </Radio.Group>
            </Form.Item>
          )}

          {(msg == '楼栋卡' || msg == '梯控启停卡') && (
            <Form.Item
              label={intl.formatMessage({ id: 'Table.Building' })}
              name="build"
              rules={[
                { required: true, message: intl.formatMessage({ id: 'Table.Select Building' }) },
              ]}
              initialValue={defaultChecked}
            >
              <CheckboxGroup options={plainOptions} value={checkedList} onChange={onChange} />
            </Form.Item>
          )}
          <Form.Item
            label={intl.formatMessage({ id: 'ManageCards.expiration date' })}
            name="timer"
            rules={[
              {
                required: true,
                message: intl.formatMessage({ id: 'ManageCards.Please select expiration date' }),
              },
            ]}
            initialValue={checkIntimer}
          >
            <DatePicker showTime format="YYYY-MM-DD HH:mm:ss" style={{ width: '300px' }} />
          </Form.Item>

          <Form.Item<any>
            label={intl.formatMessage({ id: "ManageCards.Cardholder's name" })}
            name="username"
            rules={[
              {
                required: true,
                message: intl.formatMessage({ id: "ManageCards.Please enter cardholder's name" }),
              },
            ]}
          >
            <Input
              style={{ width: 300 }}
              placeholder={intl.formatMessage({ id: "ManageCards.Please enter cardholder's name" })}
            />
          </Form.Item>

          {msg != '梯控启停卡' &&
            msg != '常开卡' &&
            msg != '卫生卡' &&
            msg != '层控卡' &&
            msg != '楼栋卡' &&
            msg != '总卡' &&
            msg != '授权卡' &&
            msg != '员工卡' && (
              <Form.Item
                label={intl.formatMessage({ id: 'ManageCards.Card permissions' })}
                name="excludeNumber"
                // rules={[{ required: true, message: '请选择权限!' }]}
                initialValue={['开反锁']}
              >
                <Checkbox.Group value={excludeNumber}>
                  <Checkbox value="开反锁">
                    {intl.formatMessage({ id: 'ManageCards.Unlock the door.' })}
                  </Checkbox>
                  <Checkbox value="静音">
                    {intl.formatMessage({ id: 'ManageCards.Silent Unlocking' })}
                  </Checkbox>
                  &emsp;
                </Checkbox.Group>
              </Form.Item>
            )}
          {/* ============================================================================= */}
          {msg == '授权卡' && (
            <Form.Item
              name="price"
              label={intl.formatMessage({ id: 'ManageCards.Authorization Time' })}
            >
              <span>
                <Input
                  type="text"
                  value={values.number || number}
                  onChange={onNumberChange}
                  style={{ width: 100 }}
                />
                <Select
                  value={values.currency || currency}
                  style={{ width: 80, margin: '0 8px' }}
                  onChange={onCurrencyChange}
                >
                  <Option value="fen">{intl.formatMessage({ id: 'card.minute' })}</Option>
                  <Option value="shi">{intl.formatMessage({ id: 'ManageCards.hour' })}</Option>
                </Select>
              </span>
            </Form.Item>
          )}

          {msg == '应急卡' && (
            <Form.Item
              label={intl.formatMessage({ id: 'ManageCards.Option' })}
              name="excludeNumber2"
            >
              <Checkbox.Group value={excludeNumber2}>
                <Checkbox value={1}>
                  <span style={{ color: '#D4D4D4' }}>
                    {intl.formatMessage({ id: 'ManageCards.Lost Actron' })}
                  </span>
                </Checkbox>
                &emsp;
              </Checkbox.Group>
            </Form.Item>
          )}
          <Form.Item
            wrapperCol={{
              offset: msg == '员工卡' || msg == '层控卡' || msg == '卫生卡' ? 8 : 3,
              span: 16,
            }}
          >
            <Button type="primary" htmlType="submit">
              {intl.formatMessage({ id: 'ManageCards.Write card' })}
            </Button>
          </Form.Item>
        </Form>
      </div>
    </>
  );
};

export default Rightbuildings;
